<template>
    <div class="views-dingdanwancheng-detail">
        <div>
            <el-card class="box-card">
                <template #header>
                    <div class="clearfix">
                        <span class="title"> 详情 </span>
                    </div>
                </template>

                <div id="printdetail">
                    <el-descriptions class="margin-top" :column="3" border>
                        <el-descriptions-item label="订单号"> {{ map.dingdanhao }} </el-descriptions-item>
                        <el-descriptions-item label="总价"> {{ map.zongjia }} </el-descriptions-item>
                        <el-descriptions-item label="商家"> {{ map.shangjia }} </el-descriptions-item>
                        <el-descriptions-item label="购买人姓名"> {{ map.goumairenxingming }} </el-descriptions-item>
                        <el-descriptions-item label="购买人"> {{ map.goumairen }} </el-descriptions-item>
                        <el-descriptions-item label="完成时间"> {{ map.addtime }} </el-descriptions-item>
                    </el-descriptions>

                    <el-descriptions direction="vertical" class="margin-top" :column="1" border>
                        <el-descriptions-item label="订单商品">
                            <div id="dataListdingdanshangpin" style="text-align: left">
                                <table class="table table-hover">
                                    <thead>
                                        <tr>
                                            <th>商品编号</th>
                                            <th>商品名称</th>
                                            <th>商品分类</th>
                                            <th>商品图片</th>
                                            <th>价格</th>
                                            <th>发布人</th>
                                            <th>购买数量</th>
                                            <th>小计</th>
                                            <th>购买人</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <tr v-for="dataMap in dataSets">
                                            <td>{{ dataMap.shangpinbianhao }}</td>
                                            <td>{{ dataMap.shangpinmingcheng }}</td>
                                            <td><e-select-view module="shangpinfenlei" :value="dataMap.shangpinfenlei" select="id" show="fenleiming"></e-select-view></td>
                                            <td>
                                                <div style="width: 100%; max-width: 120px">
                                                    <e-img :src="dataMap.shangpintupian" type="list"></e-img>
                                                </div>
                                            </td>
                                            <td>{{ dataMap.jiage }}</td>
                                            <td>{{ dataMap.faburen }}</td>
                                            <td>{{ dataMap.goumaishuliang }}</td>
                                            <td>{{ dataMap.xiaoji }}</td>
                                            <td>{{ dataMap.goumairen }}</td>
                                        </tr>
                                    </tbody>
                                </table>
                            </div>
                        </el-descriptions-item>
                        <el-descriptions-item label="完成备注"> {{ map.wanchengbeizhu }} </el-descriptions-item>
                    </el-descriptions>
                </div>
                <div class="no-print">
                    <el-button @click="$router.go(-1)">返回</el-button>
                    <el-button @click="$print('#printdetail')">打印</el-button>
                </div>
            </el-card>
        </div>
    </div>
</template>

<script setup>
    import http from "@/utils/ajax/http";
    import DB from "@/utils/db";

    import { ref, reactive, watch, computed } from "vue";
    import { useRoute } from "vue-router";
    import { session } from "@/utils/utils";
    import { extend } from "@/utils/extend";
    import { useDingdanwanchengFindById, canDingdanwanchengFindById } from "@/module";

    const route = useRoute();

    // 获取详情页面的一行数据,当url参数id变更时，自动
    const map = useDingdanwanchengFindById(route.query.id);
    // 当url参数id变更时，自动更新map中的数据
    watch(
        () => route.query.id,
        (id) => {
            canDingdanwanchengFindById(id).then((res) => {
                extend(map, res);
            });
        }
    );
    // end 获取详情页面的一行数据

    const dataSets = DB.name("dingdanwanchengdingdanshangpin").where("dingdanwanchengid", route.query.id).order("id asc").selectRef();
</script>

<style scoped lang="scss">
    .views-dingdanwancheng-detail {
    }
</style>
